package com.level2app.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.QuickViewHolder;
import com.level2app.R;

/**
 * Created by S
 * time 2024/8/21
 */
public class CategoryAllAdapter extends BaseQuickAdapter<String, QuickViewHolder> {
    private int[] existenceImgData = new int[]{R.mipmap.icon_cate_hotel_resort, R.mipmap.icon_cate_grand_open,
            R.mipmap.icon_cate_live_music, R.mipmap.icon_cate_tourism};
    private int[] noExistenceImgData = new int[]{R.mipmap.icon_cate_app, R.mipmap.icon_cate_beverages,
            R.mipmap.icon_cate_certifications, R.mipmap.icon_cate_chiropractor, R.mipmap.icon_cate_day_spa,
            R.mipmap.icon_cate_food, R.mipmap.icon_cate_experience, R.mipmap.icon_cate_fitness,
            R.mipmap.icon_cate_med_spas, R.mipmap.icon_cate_merchandise, R.mipmap.icon_cate_salon,
            R.mipmap.icon_cate_sports_events, R.mipmap.icon_cate_air_travel, R.mipmap.icon_cate_sea_travel};
    private int tag;//1--已存在的分类，2--不存在的分类

    public CategoryAllAdapter(int tag) {
        this.tag = tag;
    }

    @Override
    protected void onBindViewHolder(@NonNull QuickViewHolder holder, int i, @Nullable String s) {
        holder.setImageResource(R.id.iconIv, tag == 1 ? existenceImgData[i] : noExistenceImgData[i]);
        holder.setText(R.id.nameTv, s);
        holder.setTextColor(R.id.nameTv, tag == 1 ? ContextCompat.getColor(getContext(), R.color.color_111827) :
                ContextCompat.getColor(getContext(), R.color.color_7f7f7f));
    }

    @NonNull
    @Override
    protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new QuickViewHolder(R.layout.item_categories_all, viewGroup);
    }
}
